/*
 * hash_tests.c
 *
 *  Created on: 02/11/2010
 *      Author: Rafael
 *
 *  Description: test routines for the hash map container
 */


#include <stdio.h>
#include <stdlib.h>
#include "../DataCarriers/linked_list.h"
#include "../DataCarriers/hash.h"

int include()
{
	hash hm = hm_create();
	hm_add(hm, "item1");
	hm_add(hm, "item2");
	hm_add(hm, "item3");
	hm_add(hm, "item4");
	hm_add(hm, "item5");
	hm_add(hm, "item6");
	hm_profile(hm);
	return 1;
}

int find()
{
	hash hm = hm_create();
	hm_add(hm, "item1");
	hm_add(hm, "item2");
	hm_add(hm, "item3");
	hm_add(hm, "item4");
	hm_add(hm, "item5");
	hm_add(hm, "item6");
	hm_profile(hm);

	printf("item1 is in pos: %d\n",hm_find(hm, "item1"));
	printf("item6 is in pos: %d\n",hm_find(hm, "item6"));
	printf("item0 is in pos: %d\n",hm_find(hm, "item0"));

	return 1;
}

int delete()
{
	hash hm = hm_create();
	hm_add(hm, "item1");
	hm_add(hm, "item2");
	hm_add(hm, "item3");
	hm_add(hm, "item4");
	hm_add(hm, "item5");
	hm_add(hm, "item6");
	hm_profile(hm);

	hm_del(hm, "item5");

	printf("item1 is in pos: %d\n",hm_find(hm, "item1"));
	printf("item5 is in pos: %d\n",hm_find(hm, "item5"));
	printf("item0 is in pos: %d\n",hm_find(hm, "item0"));

	return 1;
}

int main(int argc, char** argv)
{
	printf("start\n");
	include();
	find();
	delete();
	printf("end\n");
	return 0;
}
